var prefix="/role/";
$(function () {
	valid();
});
$.validator.setDefaults({
    submitHandler: function() {
    	save();
    }
});
function save(){
    var config={
			url : prefix+"/save",
			data:getFormJson("signupForm"),
	}
	EasyAjax.post_json(config,function(r){
		layer.msg(r.msg);
		if (r.code == 0){
			parent.reLoad();
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		} 
	});
	
}
function valid(){
    var icon = "<i class='fa fa-times-circle'></i>";
    $("#signupForm").validate({
        rules:{
        	roleName: {
        		 required: true,
                 maxlength: 10,
        	},
        	roleSign: {
                required: true,
                maxlength: 15,
                isStringAndNum:true
            },
        },
        messages: {
        	roleName: {
        		required:icon + "请输入角色名称",
        		maxlength:icon + "最多10个字符",
        	},
        	roleSign: {
        		required:icon + "请输角色标识",
        		maxlength:icon + "最多15个字符",
        		isStringAndNum:icon + "只能输入英文和数字",
        	}
        }
    });
}

